package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    /**
     * 根据用户id和菜品id查询购物车数据
     * @param shoppingCart
     * @return
     */
    ShoppingCart getInfo(ShoppingCart shoppingCart);

    /**
     * 更新购物车数据
     * @param userCart
     */
    void update(ShoppingCart userCart);

    /**
     * 插入购物车数据
     * @param userCart
     */
    void insert(ShoppingCart userCart);

    /**
     * 根据用户id查询购物车
     * @param shoppingCart
     * @return
     */
    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     * 删除购物车数据其中之一
     * @param shoppingCart
     */
    void deleteOne(ShoppingCart shoppingCart);

    /**
     * 清空购物车
     * @param currentId
     */
    @Delete("delete from shopping_cart where user_id = #{currentId}")
    void deleteAll(Long currentId);

    /**
     * 批量插入购物车数据
     * @param shoppingCartList
     */
    void insertBatch(List<ShoppingCart> shoppingCartList);
}
